<?php
class IndexAction extends BaseAction
{
    function _initialize()
    {
        $this->assign('nav', 1);
        parent::_initialize();
    }

    /**
     * 网站首页
     */
    public function index()
    {
        $slider = $this->getSlide();
        $dis = $this->getDis();
        $bus = $this->getCityBus();
        $mallDis = $this->getMallDis();
        $this->getBulletin();
        $cookieName = 'user_login_email';
        $userLoginEmail = Cookie::get($cookieName);
        if (!empty($userLoginEmail)) {
            $this->assign('email', $userLoginEmail);
        }
        $this->getHomeLinks();
        //获取当前城市商圈
        $this->assign('slider', $slider);
        $this->assign('dis', $dis);
        $this->assign('bus', $bus);
        $this->assign('mallDis', $mallDis);
        $this->display();
    }

    /**
     * 公告首页列表获取
     * @author Ice <iceinto@mallog.com.cn>
     */
    private function getBulletin()
    {
        $bulletins = $this->getCityCache('home-bulletin');
        if (!$bulletins) {
            $bulletins = D('Bulletin')->getIndexList();
            $this->setCityCache('home-bulletin', $bulletins, 3600);
        }
        $this->assign('bulletins', $bulletins);
    }

    /**
     *  首页获取最新打折信息
     * @author Ice <iceinto@mallog.com.cn>
     */
    private function getDis()
    {
        $dis = $this->getCityCache('home-dis');
        if (!$dis) {
            $dis = D('BrandNews')->getIndexData();
            $this->setCityCache('home-dis', $dis, 60);
        }
        return $dis;
    }

    /**
     * 获取首页友情链接
     * @author Ice <iceinto@mallog.com.cn>
     */
    private function getHomeLinks()
    {

        $links = $this->getCityCache('home-links');
        if (empty($links)) {
            $links = D('Link')->getHomeList();
            $this->setCityCache('home-links', $links, 3600);
        }
        $this->assign('links', $links);
    }
}

?>